package com.example.Controller;

import com.example.entity.Comment;
import com.example.entity.Comments;
import com.example.service.CommentsService;
import com.example.utils.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * The type Comments controller.
 * @author XingGao
 */
@CrossOrigin //跨域
@RestController
@RequestMapping(value = "/comments")
public class CommentsController {
    @Autowired
    private CommentsService service;


    /**
     * Add controllers result data.
     *
     * @param comments the comments
     * @return the result data
     */
    @PostMapping(value = "addControllers")
    public ResultData addControllers(@RequestBody Comments comments) {

        ResultData resultData = service.addConments(comments);
        return resultData;
    }

    /**
     * Gets controllers.
     *
     * @param comments the comments
     * @return the controllers
     */
    @PostMapping(value = "getControllers")
    public ResultData getControllers(@RequestBody Comments comments) {
        ResultData resultData = service.getComments(comments);
        return resultData;
    }

    /**
     * Add controller result data.
     *
     * @param comment the comment
     * @return the result data
     */
    @PostMapping(value = "addController")
    public ResultData addController(@RequestBody Comment comment) {

        ResultData resultData = service.addConment(comment);
        return resultData;
    }

}
